package cn.tedu.yl.register.controller;

import cn.tedu.yl.base.response.JsonResult;
import cn.tedu.yl.register.pojo.dto.RegisterQuery;
import cn.tedu.yl.register.pojo.dto.RegisterSaveParam;
import cn.tedu.yl.register.pojo.vo.RegisterVO;
import cn.tedu.yl.register.service.RegisterService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/v1/register")
public class RegisterController {
    @Autowired
    private RegisterService registerService;

    @PostMapping("save")
    public JsonResult save(RegisterSaveParam registerSaveParam){
        registerService.save(registerSaveParam);
        return JsonResult.ok("操作成功");
    }

    @GetMapping("select")
    public JsonResult select(RegisterQuery registerQuery){
        List<RegisterVO>  list = registerService.select(registerQuery);
        return JsonResult.ok(list);
    }
}
